<template>
	<view>
		
		<view class="user-header">
			<image :src="userinfo.avatar"></image>
			<view class="user-info">
				<text class="user-nickname">{{userinfo.user_nickname}}</text>
				<!-- <text class="user-address">{{userinfo.address}}</text> -->
			</view>
			
			<view class="edit-info" @click="toSetting">
				<text>编辑资料</text><u-icon name="arrow-right"></u-icon>
			</view>
		</view>
		
		<view class="nav-box" @click="toUrl('/pages/order/list')">
			<image src="/static/icon-5.png"></image><text>认证列表</text><u-icon name="arrow-right"></u-icon></view>
			<!-- 
		<view class="nav-box" @click="toUrl('/pages/user/coupon')">
			<image src="/static/icon-7.png"></image><text>优惠券管理</text><u-icon name="arrow-right"></u-icon></view> -->
			
		<!-- <view class="nav-box" @click="toUrl('/pages/user/scanlog')">
			<image src="/static/icon-5.png"></image><text>扫码日志</text><u-icon name="arrow-right"></u-icon></view> -->
		
		<view class="nav-box" @click="toUrl('/pages/user/aboutus')">
			<image src="/static/icon-3.png"></image><text>关于我们</text><u-icon name="arrow-right"></u-icon></view>
		
		
		
		<view class="submit" style="background-color: #C0C4CC; color: #FFFFFF; text-align: center; height: 88rpx; text-align: center; margin: 32rpx; line-height: 88rpx; border-radius: 10rpx;" @click="logout">
			<text>退出</text>
		</view>
		
	</view>
</template>
<style lang="scss">
	
	.nav-box{
		display: flex;
		flex-direction: row;
		align-items: center;
		background-color: #FFFFFF;
		margin: 24rpx 0;
		padding: 0 24rpx;
		line-height: 108rpx;
		height: 108rpx;
		image{
			width: 50rpx; height:50rpx;
		}
		text{
			flex: 1;
			margin-left: 24rpx;
			font-size: 28rpx;
		}
	}
	
	
	.user-header{
		display: flex;
		flex-direction: row;
		background-color: #2e8bf0;
		padding: 66rpx 42rpx;
		
		.edit-info{
			position: absolute;
			top: 96rpx;
			right: 0;
			width: 198rpx;
			height: 68rpx;
			line-height: 68rpx;
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: center;
			background-color: rgba(0,0,0,0.2); border-radius: 34rpx 0 0rpx 34rpx;
			color: #FFFFFF;
		}
		
		image{
			width: 120rpx;
			height: 120rpx;
			border-radius: 50%;
			border: #ffffff solid 4rpx;
		}
		.user-info{
			display: flex;
			flex-direction: column;
			margin-left: 36rpx;
			justify-content: center;
			text{
				color: #FFFFFF;
			}
			.user-nickname{
				font-size: 42rpx; font-weight: bold;
			}
			.user-address{
				margin-top: 20rpx;
				font-size: 24rpx;
			}
		}
	}
</style>
<script>
	export default {
		data() {
			return {
				tabcurrent:0,
				list:this.$u.api.tablist,
				userinfo:{}
			}
		},
		async onShow(){
			this.isLogin = uni.getStorageSync('login');
			this.$u.api.getUserInfo().then(res => {
				this.userinfo = res.data;
				this.avatar = res.data.avatar;
			});
		},
		methods: {
			toSetting(){
				uni.navigateTo({
					url:"/pages/user/setting"
				})
			},
			toUrl(url){
				uni.navigateTo({
					url:url
				})
			},
			logout(){
				uni.removeStorageSync('user');
				uni.removeStorageSync('token');
				uni.removeStorageSync('login');
				setTimeout(res => {
					uni.navigateTo({
						url:"/pages/user/login"
					})
				},1000);
			}
		}
	}
</script>

<style>

</style>
